<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class OtherOrder extends Model
{
    // Table
    protected $table = 'other_orders';

    // The attributes that aren't mass assignable.
    protected $guarded = ['referer'];

	protected $dates = ['started_at', 'designed_at', 'produced_at', 'finished_at'];

    protected $casts = [
        'languages' => 'array'
    ];

    // 设计师
    public function designer()
    {
        return $this->belongsTo('App\Models\User', 'designer_id');
    }

    // 制作员
    public function programmer()
    {
        return $this->belongsTo('App\Models\User', 'programmer_id');
    }

    // 录入员
    public function inputer()
    {
        return $this->belongsTo('App\Models\User', 'inputer_id');
    }

    public function setDomainAttribute($value)
    {
        $this->attributes['domain'] = str_replace('http://', '', $value);
    } 
}
